From ce052fe55d9c4420645aa1f87d88ec7c33e45eda Mon Sep 17 00:00:00 2001 From: Robert Lipe Date: Wed, 28 Jun 2017 14:10:37 -0500 Subject: [PATCH] Update skytraq UTC/GPS time handling. Update tables with latest two constant changes. Add command line option for overriding this. --- reference/skytraq-artificial.gpx | 10 ++++---- skytraq.cc | 23 +++++++++++++++++++ .../options/skytraq-gps_utc_offset.xml | 18 +++++++++++++++ 3 files changed, 46 insertions(+), 5 deletions(-) create mode 100644 xmldoc/formats/options/skytraq-gps_utc_offset.xml diff --git a/reference/skytraq-artificial.gpx b/reference/skytraq-artificial.gpx index d9ce07151..16412ee78 100644 --- a/reference/skytraq-artificial.gpx +++ b/reference/skytraq-artificial.gpx @@ -257,31 +257,31 @@ 435.413042 - + 2.777778 TP0039 435.413042 - + 27.777779 TP0040 435.413042 - + 27.777779 TP0041 435.413042 - + 55.555557 TP0042 435.413042 - + 55.555557 TP0043 diff --git a/skytraq.cc b/skytraq.cc index 914ecd27b..ec7c959cc 100644 --- a/skytraq.cc +++ b/skytraq.cc @@ -68,6 +68,7 @@ static char* opt_dump_file = 0; /* dump raw data to this file (optional) */ static char* opt_no_output = 0; /* disable output? (0/1) */ static char* opt_set_location = 0; /* set if the "targetlocation" options was used */ static char* opt_configure_logging = 0; +static char* opt_gps_utc_offset = 0; static arglist_t skytraq_args[] = { @@ -111,6 +112,10 @@ arglist_t skytraq_args[] = { "no-output", &opt_no_output, "Disable output (useful with erase)", "0", ARGTYPE_BOOL, ARG_NOMINMAX }, + { + "gps_utc_offset", &opt_gps_utc_offset, "Seconds that GPS time tracks UTC (0: best guess)", + "0", ARGTYPE_INT, ARG_NOMINMAX + }, ARG_TERMINATOR }; @@ -124,6 +129,10 @@ arglist_t skytraq_fargs[] = { "last-sector", &opt_last_sector, "Last sector to be read from the file (-1: read till empty sector)", "-1", ARGTYPE_INT, "-1", "65535" }, + { + "gps_utc_offset", &opt_gps_utc_offset, "Seconds that GPS time tracks UTC (0: best guess)", + "0", ARGTYPE_INT, ARG_NOMINMAX + }, ARG_TERMINATOR }; @@ -587,6 +596,12 @@ gpstime_to_timet(int week, int sec) time_t gps_timet = 315964800; /* Jan 06 1980 0:00 UTC */ gps_timet += (week+1024)*7*SECONDS_PER_DAY + sec; + int override = atoi(opt_gps_utc_offset); + if (override) { + gps_timet -= override; + return gps_timet; + } + /* leap second compensation: */ gps_timet -= 13; /* diff GPS-UTC=13s (valid from Jan 01 1999 on) */ if (gps_timet >= 1136073600) { /* Jan 01 2006 0:00 UTC */ @@ -598,6 +613,14 @@ gpstime_to_timet(int week, int sec) if (gps_timet >= 1341100800) { /* Jul 01 2012 0:00 UTC */ gps_timet--; /* GPS-UTC = 16s */ } + if (gps_timet >= 1435708800) { /* Jul 01 2015 0:00 UTC */ + gps_timet--; /* GPS-UTC = 17s */ + } + if (gps_timet >= 1483228800) { /* Jan 01 2017 0:00 UTC */ + gps_timet--; /* GPS-UTC = 18s */ + } + // Future: Consult http://maia.usno.navy.mil/ser7/tai-utc.dat + // use http://www.stevegs.com/utils/jd_calc/ for Julian to UNIX sec return gps_timet; /* returns UTC time */ } diff --git a/xmldoc/formats/options/skytraq-gps_utc_offset.xml b/xmldoc/formats/options/skytraq-gps_utc_offset.xml new file mode 100644 index 000000000..7be726497 --- /dev/null +++ b/xmldoc/formats/options/skytraq-gps_utc_offset.xml @@ -0,0 +1,18 @@ + +gps_utc_offset is used to override the built-in table of offsets of +the offset between GPS time and UTC time. This chipset reports only +GPS time to the host and relies on software to know every time an adjustment +is made. Since GPS time offsets can change without a new version of GPSBabel +is released, those that care about total accuracy can override it. + + +gpsbabel +-i skytraq.bin,gps_utc_offset=15 -f filename.bin + + +Indicates that GPS is ahead of UTC by fifteen seconds, as was the case in 2009. + + + +Consult formal eplanation of GPS time vs. UTC time if you're into that. + -- 2.30.2